﻿using System;
namespace Mota.XMLControls
{
    //abstract factory
    public abstract class GuiFactory
    {
        public abstract GuiLabel CreateLabel();
        public abstract GuiGroupBox CreateGroupBox();
        public abstract GuiComboBox CreateComboBox();
        public abstract GuiTextBox CreateTextBox();
        public abstract GuiSplitter CreateSplitter();
        public abstract GuiSplitterPanel CreateSplitterPanel(GuiSplitter parent);
        public abstract GuiTabControl CreateTabControl();
        public abstract GuiTab CreateTab();
        public abstract GuiWebBrowser CreateWebBrowser();
        public abstract GuiRichText CreateRichText();
        public abstract GuiDateTime CreateDateTime();
        public abstract GuiImageBox CreateImageBox();
        public abstract GuiCheckBox CreateCheckBox();
        public abstract GuiMaskText CreateMaskText();
        public abstract GuiNumeric CreateNumeric();
        public abstract GuiCheckedList CreateCheckedList();
        public abstract GuiTreeView CreateTreeView();
        public abstract GuiColor CreateColor();
        public abstract GuiTime CreateTime();
        public abstract GuiTrackBar CreateTrackBar();
        public abstract GuiPanel CreatePanel();
        public abstract GuiRadioGroup CreateRadioGroup();
        public abstract GuiListBox CreateListBox();
        public abstract GuiCheckedComboBox CreateCheckedComboBox();
        public abstract GuiRangeTrackBar CreateRangeTrackBar();
        public abstract GuiDictionaryDecorator CreateDictionaryDecorator(GuiControl decorated);

        public virtual GuiControl CreateGuiControl(String controlName,params object[] parameters)
        {
            GuiControl cntrl = null;
            switch (controlName)
            {
                case "GroupBox":
                    cntrl = GuiBuilder.CurrentFactory.CreateGroupBox();
                    break;
                case "WebBrowser":
                    cntrl = GuiBuilder.CurrentFactory.CreateWebBrowser();
                    break;
                case "ComboBox":
                    cntrl = GuiBuilder.CurrentFactory.CreateComboBox();
                    break;
                case "Label":
                    cntrl = GuiBuilder.CurrentFactory.CreateLabel();
                    break;
                case "TextBox":
                    cntrl = GuiBuilder.CurrentFactory.CreateTextBox();
                    break;
                case "Splitter":
                    cntrl = GuiBuilder.CurrentFactory.CreateSplitter();
                    break;
                case "SplitterPanel":
                    if((parameters!=null)&&(parameters.Length>0)&&(parameters[0] is GuiSplitter))
                    {
                        cntrl = GuiBuilder.CurrentFactory.CreateSplitterPanel(parameters[0] as GuiSplitter);
                    }
                    break;
                case "TabControl":
                    cntrl = GuiBuilder.CurrentFactory.CreateTabControl();
                    break;
                case "Tab":
                    cntrl = GuiBuilder.CurrentFactory.CreateTab();
                    break;
                case "RichText":
                    cntrl = GuiBuilder.CurrentFactory.CreateRichText();
                    break;
                case "DateTime":
                    cntrl = GuiBuilder.CurrentFactory.CreateDateTime();
                    break;
                case "ImageBox":
                    cntrl = GuiBuilder.CurrentFactory.CreateImageBox();
                    break;
                case "CheckBox":
                    cntrl = GuiBuilder.CurrentFactory.CreateCheckBox();
                    break;
                case "MaskText":
                    cntrl = GuiBuilder.CurrentFactory.CreateMaskText();
                    break;
                case "Numeric":
                    cntrl = GuiBuilder.CurrentFactory.CreateNumeric();
                    break;
                case "CheckedList":
                    cntrl = GuiBuilder.CurrentFactory.CreateCheckedList();
                    break;
                case "TreeView":
                    cntrl = GuiBuilder.CurrentFactory.CreateTreeView();
                    break;
                case "Color":
                    cntrl = GuiBuilder.CurrentFactory.CreateColor();
                    break;
                case "Time":
                    cntrl = GuiBuilder.CurrentFactory.CreateTime();
                    break;
                case "TrackBar":
                    cntrl = GuiBuilder.CurrentFactory.CreateTrackBar();
                    break;
                case "Panel":
                    cntrl = GuiBuilder.CurrentFactory.CreatePanel();
                    break;
                case "RadioGroup":
                    cntrl = GuiBuilder.CurrentFactory.CreateRadioGroup();
                    break;
                case "CheckedComboBox":
                    cntrl = GuiBuilder.CurrentFactory.CreateCheckedComboBox();
                    break;
                case "ListBox":
                    cntrl = GuiBuilder.CurrentFactory.CreateListBox();
                    break;
                case "RangeTrackBar":
                    cntrl = GuiBuilder.CurrentFactory.CreateRangeTrackBar();
                    break;
            }
            return cntrl;
        }

        //TODO: think how to avoid this 
        public abstract void AddGuiToVisual(GuiControl guiControl,object VisualControl);
    }
}
